package 多线程.课后作业.M3;

/**
 * 3)、模拟三个老师同时分发30份笔试试卷，每个老师相当于一个线程。
 */
public class Test extends Thread{
    private int time = 30;

        public  void run() {
                while (true){
                    if (this.time > 0) {
                        System.out.println(Thread.currentThread().getName() + "\t\t正在发第--" + this.time--+"张试卷！");
                    }else {
                        break;
                    }
                    //Thread.yield();
                }


        }

    public static void main(String[] args) {
        Thread thread = new Test();
        Thread thread1 = new Thread(thread,"张老师");
        Thread thread2 = new Thread(thread,"王老师");
        Thread thread3 = new Thread(thread,"李老师");
        thread1.start();
        thread2.start();
        thread3.start();
    }
}
